package de.stefanocke.roo.wicket.persistence;

import java.util.List;

import org.springframework.roo.classpath.layers.MemberTypeAdditions;

import de.stefanocke.roo.wicket.MidUtils;
import de.stefanocke.roo.wicket.base.ModelClassAwareItdMetadataBase;
import de.stefanocke.roo.wicket.base.ModelClassAwareMetadataCreationParams;
import de.stefanocke.roo.xtend.Parameter;

/**

 */
public class PersistenceBindingMetadata extends
		ModelClassAwareItdMetadataBase<PersistenceBindingAnnotationValues> {
	public static final MidUtils midUtils = MidUtils
			.get(PersistenceBindingMetadata.class);

	private MemberTypeAdditions queryMetadata;
	private MemberTypeAdditions countQueryMetadata;
	private List<Parameter> customQueryParams;
	private PersistenceMetadataDetails persistenceDetails;

	public PersistenceBindingMetadata(
			ModelClassAwareMetadataCreationParams<PersistenceBindingAnnotationValues> cmcp,
			PersistenceMetadataDetails persistenceDetails, MemberTypeAdditions queryMetadata,
			MemberTypeAdditions countQueryMetadata,
			List<Parameter> customQueryParams) {
		super(cmcp, new PersistenceMetadataItdBuilder());
		this.queryMetadata = queryMetadata;
		this.countQueryMetadata = countQueryMetadata;
		this.customQueryParams = customQueryParams;
		this.persistenceDetails = persistenceDetails;
		buildItdTypeDetails();
	}

	public MemberTypeAdditions getQueryMetadata() {
		return queryMetadata;
	}

	public MemberTypeAdditions getCountQueryMetadata() {
		return countQueryMetadata;
	}

	public List<Parameter> getCustomQueryParams() {
		return customQueryParams;
	}

	public boolean isCustomQuery() {
		return getAnnotationValues().queryName != null;
	}
	
	public PersistenceMetadataDetails getPersistenceDetails() {
		return persistenceDetails;
	}

}
